<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>医生查看排班页面</title>
    <base th:href="@{http://localhost:9090/}"/>
    <script type="text/javascript" th:src="@{/js/jquery-3.2.1.min.js}"></script>
        <script type="text/javascript">
            $(function (){
                $.ajax({
                    url:"/lsy/getWorkForcesList",
                    type:"GET",
                    datatype:"josn",
                    success:function (workForcesList) {
                        if (workForcesList.flag=='1'){
                            if (workForcesList.workForcesList!=null){
                                show(workForcesList.workForcesList);
                            }else {
                                alert("查询结果为空！")
                            }
                        }else {
                            alert("查询结果为空！")
                        }
                    },
                    error:function (workForcesList) {
                        alert("查询排班失败!")
                    }
                })
            })
            Date.prototype.format=function (format){
                var o={
                    "M+" : this.getMonth() + 1, // month
                    "d+" : this.getDate(), // day
                    "H+" : this.getHours(), // hour
                    "m+" : this.getMinutes(), // minute
                    "s+" : this.getSeconds(), // second
                    "q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
                    "S" : this.getMilliseconds()
                }
                if (/(y+)/.test(format)){
                    format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length));
                }
                for (var k in  o){
                    if (new RegExp("("+k+")").test(format)){
                        format=format.replace(RegExp.$1,RegExp.$1.length==1 ? 0[k]: ("00" +o[k]).substr((""+o[k]).length));
                    }
                }
                return format;
            }

            function show(workForcesList){
                var workForces="";
                for (var i = 0; i < workForcesList.length; i++) {
                    workForces +='<tr>'
                        +'<td>'+workForcesList[i].departmentName+'</td>'
                        +'<td>'
                        +'<a th:href="@{/lsy/togetWorkForcesBydid(workforcesDoctor=${workForcesList[i].workforcesDoctor})}">'
                        + workForcesList[i].dname
                        +'</a>'
                        +'</td>'
                        +'<td>'+new Date(workForcesList[i].workforcesTime).format("yyyy-MM-dd")+'</td>'
                        +'<td>'+new Date(workForcesList[i].onTime).format("yyyy-MM-dd HH:mm:ss")+'</td>'
                        +'<td>'+new Date(workForcesList[i].downTime).format("yyyy-MM-dd HH:mm:ss")+'</td>'
                        +'<td>'+workForcesList[i].maxRegistration+'</td>'
                        +'<td>'+workForcesList[i].registration+'</td>'
                        +'</tr>';
                }
                $("#root").append(workForces);
            }
        </script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        table {
            width: 800px;
            border-collapse: collapse;
            margin: auto;
            margin-top: 60px;
        }

        table tr {
            display: -webkit-flex;
            display: flex;
        }

        table tr th,
        table tr td {
            flex: 1;
            padding: 10px 0;
            text-align: center;
            border: 1px solid #e1e8f6;
        }

        table tr th {
            background-color: #dddddd;
        }
    </style>
</head>
<body>
    <div id="cun">

        <table id="all-requst">
            <thead>
                <tr>
                    <th>科室名称</th>
                    <th>医生姓名</th>
                    <th>排班日期</th>
                    <th>上班时间</th>
                    <th>下班时间</th>
                    <th>最大挂号数</th>
                    <th>剩余挂号数</th>
                </tr>
            </thead>
            <tbody id="root">

            </tbody>
        </table>
    </div>
</body>
</html>